/*
 * @Author: 亚亚
 */
/*
 * @Author: 亚亚
 */
/*
 * @Author: 亚亚
 */
/*
 * @Author: 亚亚
 */
import { createRouter, createWebHashHistory } from 'vue-router'
import { setupLayouts } from 'virtual:generated-layouts'
import generatedRoutes from 'virtual:generated-pages'
import Nprogress from 'nprogress'

// const env = import.meta.env

let routes = setupLayouts(generatedRoutes)
// let baseUrl = ''
// if(env.VITE_APP_IS_PA_MICRO==='YES') {
//   baseUrl = `/#/${env.VITE_BASE_HASH_ROUTER}/${env.VITE_APP_NAME}`
// }
const router = createRouter({
  // history: createWebHashHistory(baseUrl),  //使用baseURL的话其他系统的路由也会被覆盖，应该和qiankun -> shared配置有关
  history: createWebHashHistory(),
  routes
})
router.beforeEach((to, from, next) => {
  console.log(to, 12312);
  
  if (to.path !== from.path) {
    Nprogress.start()
    // if(!to.path.includes('/micro-route/yy-micro') && env.VITE_APP_IS_PA_MICRO==='YES') { //会影响到其他子系统,原因同上
    //   next('/micro-route/yy-micro' + to.path)
    // }else {
      next()
    // }
  }
})
router.afterEach(() => {
  Nprogress.done()
})
export default router
